namespace IAM.Interface.Model
{
    using IAM.Interface.Common;
    using IAM.Interface.Model.ENUM;
    using IAM.Interface.Model.Interface;
    using System;
    using System.Text;

    public class Module : AbstractConvertObject, IConvertXml
    {
        private string _display = "";
        private string _id = "";
        private ModuleType _type = ModuleType.Delegate;

        public override object ConvertToObject()
        {
            this.ID = EnDeCoding.Decode(this.CurrentXmlNode.Attributes["ID"].InnerText);
            this.Display = EnDeCoding.Decode(this.CurrentXmlNode.Attributes["Display"].InnerText);
            string strType = this.CurrentXmlNode.Attributes["Type"].InnerText;
            switch (strType.ToLower())
            {
                case "delegate":
                    this.Type = ModuleType.Delegate;
                    goto Label_00BC;

                case "operateas":
                    this.Type = ModuleType.OperateAs;
                    break;

                case "both":
                    this.Type = ModuleType.Both;
                    break;
            }
        Label_00BC:
            return this;
        }

        public string Display
        {
            get
            {
                return this._display;
            }
            set
            {
                this._display = value;
            }
        }

        public string ID
        {
            get
            {
                return this._id;
            }
            set
            {
                this._id = value;
            }
        }

        public ModuleType Type
        {
            get
            {
                return this._type;
            }
            set
            {
                this._type = value;
            }
        }

        public string XML
        {
            get
            {
                return (this.XMLBoday + this.XMLFinis);
            }
        }

        public string XMLBoday
        {
            get
            {
                StringBuilder _xml = new StringBuilder();
                _xml.Append(" <Module");
                _xml.Append(" ID=\"" + EnDeCoding.Encode(this.ID) + "\" ");
                _xml.Append(" Display=\"" + EnDeCoding.Encode(this.Display) + "\" ");
                _xml.Append(" Type=\"" + this.Type.ToString() + "\" ");
                _xml.Append(" />");
                return _xml.ToString();
            }
        }

        public string XMLFinis
        {
            get
            {
                return "";
            }
        }
    }
}

